package com.xcenter.cabinet.util;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

	private final static String DATE_FORMAT = "yyyy-MM-dd";

	public static Date getCurrDate() {
		return new Date();
	}
	
	public static Timestamp getCurrTs() {
		return new Timestamp(System.currentTimeMillis());
	}
	
	public static String getFormatCurrDate() {
		return getFormatDate(getCurrDate(), DATE_FORMAT);
	}
	
	public static String getFormatDate(java.util.Date currDate, String format) {
		if (currDate == null) {
			return "";
		}
		SimpleDateFormat dtFormatdB = null;
		try {
			dtFormatdB = new SimpleDateFormat(format);
			return dtFormatdB.format(currDate);
		} catch (Exception e) {
			dtFormatdB = new SimpleDateFormat(DATE_FORMAT);
			try {
				return dtFormatdB.format(currDate);
			} catch (Exception ex) {
			}
		}
		return null;
	}

}
